package cn.Duo;
/*用于练习多态*/
public class Example5_1 {
    public  boolean equals(Example5_1 other){
        System.out.println("use Example equals");
        return  true;
    }

    public static void main(String[] args) {
        Object o1 = new Example5_1();
        Object o2 = new Example5_1();
        Example5_1 o3 = new Example5_1();
        Example5_1 o4 = new Example5_1();
        /*调用的是Object中的equals方法,比较地址值,返回false,不执行语句*/
        if (o1.equals(o2)){
            System.out.println("o1 is equal with o2");
        }
        /*调用的是Example5_1里的equals方法,先输出equals方法里的语句,接着返回true*/
        if(o3.equals(o4)){
            System.out.println("o3 is equal with o4");
        }
    }
}
